﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Executing the try statement.");
                throw new NullReferenceException();  //释放异常
            }
            catch (NullReferenceException e)  //捕捉特定类型异常
            {
                Console.WriteLine("{0} Caught exception #1.", e);
            }

            catch //捕获所有类型异常
            {
                Console.WriteLine("Caught exception #2.");
            }

            finally //不管是否发生异常，都会执行finally中的语句
            {
                Console.WriteLine("Executing finally block.");
            }
        }
    }
}
